package com.wbf.demo.mapper;

import com.wbf.demo.domain.Menu;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface MenuMapper {

    @Select("select m.* from menu m " +
            "left join role_menu rm " +
            "on rm.role_id in " +
            "<foreach collection='roleIdList' index='index' item='roleId' open='(' separator=',' close=')'> " +
            "'${roleId}'" +
            "</foreach> )" +
            "and rm.menu_id = m.id")
    List<Menu> getMenuListByRoleIdList(List<Long> roleIdList);

    @Select("select m.* from menu m " +
            "left join role_menu rm " +
            "on rm.role_id = #{roleId} " +
            "and rm.menu_id = m.id")
    List<Menu> getMenuListByRoleId(Long roleId);
}
